using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace HTCollections
{
    public static class CollectionsUtil
    {
        [Conditional("ENABLE_HT_COLLECTIONS_CHECKS")]
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static void CheckIndexInRange(int index, int length)
        {
            if (index < 0)
                throw new IndexOutOfRangeException("索引必须为正数");
            if (index >= length)
                throw new IndexOutOfRangeException($"索引 {index} 越界, length : {length}");
        }
    }
}